import random
num = random.randint(0, 9)
count = 0
while True:
    guess = input("请输入你猜的数字：")
    if not guess.isdigit():
        print("输入内容必须为整数！")
        continue
    guess = int(guess)
    count += 1
    if guess > num:
        print("遗憾，太大了")
    elif guess < num:
        print("遗憾，太小了")
    else:
        print("预测{}次，你猜中了！".format(count))
        break